/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package control

import dao.EmployeeDAO
import entity.Employee
import java.sql.Connection
/**
 *
 * @author Tato
 */
class ControlEmployee {
    
    EmployeeDAO dao = new EmployeeDAO()
    
   
    def addEmployee(Employee employee){
    
        key = dao.create(employee,DBConnection.establishConection())
        if(key > 0){    
            employee.id= key 
            "Empleado Agregado"
        }
        else{
            "Empleado no agregado"
        }
        
    }
    
    def deleteEmployee(Employee employee){
        
        employee.id = dao.remove(employee,DBConnection.establishConection())
        
        if(delete == true){
            "Borrado exitoso"
        }
        else{
            "Borrado falló"
        }     
    }
    
    def updateEmployee(Employee employee){
        if(dao.update(employe,DBConnection.establishConection()) > 0){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
    
     def findEmployee(Integer id){
         if(dao.find(id,DBConnection.establishConection())!= null  ){
               "Información actualizada"
            }
            
            else {
                "Información no actualizada"
            }
        
    }
	
}

